/*
 * Author Kyle Richardson
 */
package tests;

import static org.junit.Assert.*;

import java.io.IOException;
import java.util.ArrayList;

import model.Job;
import model.LMA;
import model.Volunteer;

import org.junit.Before;
import org.junit.Test;

import util.Stringer;

/**
 * Tests to make sure that the non-getter/setter 
 * methods are running properly for Job class.
 */
public class JobTest 
{
	Volunteer Tim;
	LMA Frank;
	Job myJob;
	
	/**
	 * Sets up variables for the tests.
	 * @author Kyle Richardson
	 * @author Justin Kudlo
	 */
	@Before
	public void setUp()
	{
		try {
			Stringer test = new Stringer();
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		
		Frank = new LMA(Stringer.getString(14), 
				Stringer.getString(15), 
				Stringer.getString(16), 
				Stringer.getString(17), 
				Stringer.getString(18),
				Stringer.getString(19), 
				Stringer.getString(20), 
				Stringer.getString(21),
				null);
		myJob = new Job(Stringer.getString(22), 
				Integer.parseInt(Stringer.getString(23)), 
				Integer.parseInt(Stringer.getString(24)), 
				Frank,
				Integer.parseInt(Stringer.getString(25)), 
				Integer.parseInt(Stringer.getString(26)),
				Stringer.getString(27));
		
		Tim = new Volunteer(Stringer.getString(28),
				Stringer.getString(29),
				Stringer.getString(30), 
				null, null, null, null);
	}
	
	/**
	 * Tests Schecdule of job
	 * 
	 * @author Andy Johnson
	 */
	@Test
	public void testScheduleJob()
	{
		myJob.schduleJob(
				Integer.parseInt(Stringer.getString(31)),
				Integer.parseInt(Stringer.getString(32)),
				Integer.parseInt(Stringer.getString(33)),
				Integer.parseInt(Stringer.getString(34)),
				Integer.parseInt(Stringer.getString(35)),
				Integer.parseInt(Stringer.getString(36)));
		
		assertEquals(
				Integer.parseInt(Stringer.getString(37)), 
				myJob.getStartYear());
		assertEquals(
				Integer.parseInt(Stringer.getString(38)), 
				myJob.getStartMonth());
		assertEquals(
				Integer.parseInt(Stringer.getString(39)), 
				myJob.getStartMonth());
		assertEquals(
				Integer.parseInt(Stringer.getString(40)), 
				myJob.getEndYear());
		assertEquals(
				Integer.parseInt(Stringer.getString(41)), 
				myJob.getEndMonth());
		assertEquals(
				Integer.parseInt(Stringer.getString(42)), 
				myJob.getEndDay());
	}
	
	/**
	 * This tests signs up a volunteer to a job which adds
	 * the volunteer to the array list workParty, and then
	 * creates an array list and adds the same volunteer
	 * to the list. Then checks to make sure the two array
	 * lists have the same size and both contain that 
	 * volunteer.
	 */
	@Test
	public void testsignUpForJobAsVol()
	{
		myJob.signupForJobAsVol(Tim);
		ArrayList<Volunteer> correctList = new
		ArrayList<Volunteer>();
		correctList.add(Tim);
		assertEquals(myJob.getWorkParty().size(),
				correctList.size());
		assertEquals(myJob.getWorkParty().contains(Tim),
				correctList.contains(Tim));
	}
	
	/**
	 * This test sets a volunteer as a groupleader and
	 * signs up this group leader to a job and then
	 * creates an array list and adds the same group leader
	 * to the list. Then checks to make sure the two array
	 * lists have the same size and both contain that 
	 * group leader.
	 */
	@Test
	public void testsignUpForJobAsGL()
	{
		Tim.setGLStatus(true);
		myJob.signupForJobAsGL(Tim);
		ArrayList<Volunteer> correctList = new
		ArrayList<Volunteer>();
		correctList.add(Tim);
		assertEquals(myJob.getWorkParty().contains(Tim),
				correctList.contains(Tim));
	}
	
	/**
	 * This test signs up a volunteer and then checks 
	 * if when isSignedUpFor(that volunteer) is called
	 * that it returns true because we that we signed that
	 *  volunteer up for it.
	 */
	@Test
	public void testisSignedUpFor()
	{
		myJob.signupForJobAsVol(Tim);
		assertTrue(myJob.isSignedUpFor(Tim));
	}
}
